using System.Collections;
using UnityEngine;

public class DictionaryAudioClips
{
	public AudioClip clip;

	private int _count;

	public string name;

	private IEnumerator _unload;

	public int count
	{
		get
		{
			return _count;
		}
		set
		{
			_count = value;
			if (_count > 0)
			{
				if (BCWAudioResource.Instance != null)
				{
					BCWAudioResource.Instance.Remove(name);
					if (_unload != null)
					{
						BCWAudioResource.Instance.StopCoroutine(_unload);
						_unload = null;
					}
				}
			}
			else if (_unload == null)
			{
				_unload = ClipUnloaded();
				BCWAudioResource.Instance.StartCoroutine(_unload);
			}
		}
	}

	private IEnumerator ClipUnloaded()
	{
		yield return new WaitForSeconds(10f);
		BCWAudioResource.Instance.UnloadClip(name);
		_unload = null;
	}
}
